﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Meqs.Entity;
using Meqs.Entity.Views;
using Meqs.Logic.Interface;

namespace Meqs.Logic.Implement
{
    public class ClassEvalHistoryLogic : CommonLogic<ClassEvalHistory, int>, IClassEvalHistoryLogic
    {
        #region Implementation of ICommonLogic<ClassEvalHistory, int>

        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(ClassEvalHistory entity)
        {
            return CreateObject(entity);
        }

        /// <summary>
        /// 更新对象
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(ClassEvalHistory entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public ClassEvalHistory FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount()
        {
            return FindObjectByCount();
        }

        /// <summary>
        /// 检索对象
        /// </summary>
        public IList<ClassEvalHistory> FindAll()
        {
            return FindAllObject();
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <summary>
        /// 检索对象
        /// </summary>
        public IList<ClassEvalHistory> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion

        public IList<ClassEvalHistory> FindById(int entityId, String schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("RID", entityId);
            ht.Add("SchoolMark", schoolMark);
            return FindCustomer<ClassEvalHistory>("ClassEvalHistory.FindById", ht);
        }

        public int UpdateStatus(Hashtable ht)
        {
            try
            {
                string statementName = "ClassEvalHistory.UpdateStatus";
                return ExecuteUpdate(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        public IList<ClassEvalState> GetState(int schoolYear, int term, String schoolMark, int evalID, DateTime startDay, DateTime endDay)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            ht.Add("Year", schoolYear);
            ht.Add("Term", term);
            ht.Add("EvalID", evalID);
            ht.Add("StartDate", startDay);
            ht.Add("EndDate", endDay);
            IList<ClassEvalState> result = this.ExecuteQueryForList<ClassEvalState>("ClassEvalHistory.GetState", ht);
            return result;
        }
    }
}
